package com.zhou.cloud.config.kafka;

/**
 * @descrition: 消息发送端
 * @author: zhouyongjun
 * @date: 2022/7/22
 **/
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@EnableBinding(Source.class)
public class KafkaMessageSender {
    @Autowired
    private Source channel;

    public void sendToDefaultChannel(String message) {
        channel.output().send(MessageBuilder.withPayload(message).build());
    }

}
